package ceha.application2;

import ceha.application.CEHAFicheCreation;
import ceha.application.CEHALogin;
import java.awt.*;
import java.awt.event.*;
import java.io.IOException;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.*;

public class FrameConsultationCreate {

    private static CEHALogin loginframe;
    private static CEHAFicheCreation creer;

    private static void createFormulaire() throws IOException, SQLException {
        //Create and set up the window.
        JFrame frame = new JFrame("Formulaire");
        frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        //        JLabel emptyLabel = new JLabel("");
        //        emptyLabel.setPreferredSize(new Dimension(175, 100));
        loginframe = new CEHALogin();
        creer = new CEHAFicheCreation(loginframe);
        JPanel panel = creer.getFormulaire();
        frame.getContentPane().add(panel, BorderLayout.CENTER);

        //Display the window.
        frame.pack();
        frame.setVisible(true);
    }

    private static void createCommande() throws IOException, SQLException {

        JFrame frame = new JFrame("Commandes");
        frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);


        JPanel panel = creer.getCommandes();
        frame.getContentPane().add(panel, BorderLayout.CENTER);

        //Display the window.
        frame.pack();
        frame.setVisible(true);
    }

    private static void createTable() {
        JFrame frame = new JFrame("Table");
        frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        JToolBar toolbar = creer.getToolbartable();
        frame.getContentPane().add(toolbar, BorderLayout.CENTER);

        //Display the window.
        frame.pack();
        frame.setVisible(true);
    }

    public static void main(String[] args) {
        //Schedule a job for the event-dispatching thread:
        //creating and showing this application's GUI.
        javax.swing.SwingUtilities.invokeLater(new Runnable() {

            public void run() {
                try {
                    createFormulaire();
                    createCommande();
                    createTable();
                } catch (IOException ex) {
                    Logger.getLogger(FrameConsultationCreate.class.getName()).log(Level.SEVERE, null, ex);
                } catch (SQLException ex) {
                    Logger.getLogger(FrameConsultationCreate.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        });
    }
}
